package InputPreparer;

import java.util.ArrayList;

import AggregationMethod.AggregationMethodFactory;
import AggregationMethod.AggregationMethodInterface;
import Definitions.NodeClass;
import Global.ConstantVariable;
import Global.GlobalClass;
import Sampling.SamplingAbstractClass;

public class LinkPreparerClass extends InputPreparerClass{


	AggregationMethodInterface aggregationMethod;
	int degree;
	int edgeType;
	
	public LinkPreparerClass(SamplingAbstractClass currentSampling, GlobalClass global) 
	{
		super(currentSampling, global);
		this.name = ConstantVariable.InputPreparer_Constants.LINK_INPUT;
		// TODO Auto-generated constructor stub
	}
	
	public LinkPreparerClass(int edgeType, int degree, AggregationMethodInterface aggregationMethod, SamplingAbstractClass currentSampling, GlobalClass global)
	{
		super(currentSampling, global);		
		this.name = ConstantVariable.InputPreparer_Constants.LINK_INPUT;
		this.aggregationMethod =aggregationMethod;
		this.edgeType= edgeType;
		this.degree= degree;
	}
	
	public int getDegree() {
		return degree;
	}

	public void setDegree(int degree) {
		this.degree = 1;
		
	}

	public int getEdgeType() {
		return edgeType;
	}

	public void setEdgeType(int edgeType) {
		this.edgeType = edgeType;
	}

	public AggregationMethodInterface getAggregationMethod() {
		return aggregationMethod;
	}

	public void setAggregationMethod(AggregationMethodInterface aggregationMethod) {
		this.aggregationMethod = aggregationMethod;
	}

	public ArrayList <Double> getInput(NodeClass u, int whichNodesToUseForAggregation)
	{
		ArrayList<NodeClass> neighbours = currentSampling.findNeighbours(u, whichNodesToUseForAggregation, edgeType, degree);
		return aggregationMethod.getAggregatedNeighbourVector(neighbours,degree);
	}
	
	public void print()
	{
		
	}
	
	public void Test(NodeClass u, SamplingAbstractClass currentSampling, GlobalClass global)
	{
		AggregationMethodFactory fact = new AggregationMethodFactory();
		AggregationMethodInterface aggMet = fact.createAggregationMethod(ConstantVariable.AggregationMethod_ConstantVariables.SUM, currentSampling);
		
		LinkPreparerClass prep = new LinkPreparerClass(0, 1, aggMet, currentSampling, global);
		ArrayList<Double> list = prep.getInput(u, ConstantVariable.Sampling_Constants.NODE_IS_IN_TEST_SET_FOR_THE_FOLD);
		
		
		System.out.println("Link Input Test Result :");
		for(Double f : list )
		{
			System.out.print(f+"  ");
		}
			
		System.out.println();
	}

}
